#include <string>
#include <sstream>
#include <iostream> 
using namespace std;
void swap(int m,int n,char *p);
void shuchu(char *p,int n)
{
    int len = strlen(p);
    if(n == len-1)
        {
            cout<<p<<endl;
            return;
        }
    for(int i = n;i<len;i++)
    {
        swap(i,n,p);
        shuchu(p,n+1);
        swap(i,n,p);
        
    }
}
void swap(int m,int n,char *p)
{
    if(m == n)
    return;
    char temp = p[m];
    p[m] = p[n];
    p[n] = temp; 
}
int main()
{
    char s[] = "gao";
    shuchu(s,0);
} 